import { fetchApi } from './client.ts';
import type { 
  LoginCredentials, 
  LoginResponseData,
  VerifyResponseData 
} from '../../../server/shared/types.ts';

export const authApi = {
  login: (credentials: LoginCredentials) =>
    fetchApi<LoginResponseData>('/auth/login', {
      method: 'POST',
      body: JSON.stringify(credentials),
    }),
    
  logout: () => fetchApi('/auth/logout', { method: 'POST' }),
  refreshToken: () => fetchApi<LoginResponseData>('/auth/refresh', { method: 'POST' }),
  verify: () => 
    fetchApi<VerifyResponseData>('/auth/verify', {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${localStorage.getItem('token')}`
      }
    }),
}; 